// let random = Math.floor(Math.random()*11)
function getRandom(N,M){
    return Math.floor(Math.random()*(M-N+1))+N
}

let random = getRandom(1,10)
while (true) {
    let num = +prompt(`输入你猜的数字`)
    if (num>random) {
        alert(`猜大了`)
    }else if(num<random){
        alert(`猜小了`)
    }else{
        alert(`你猜对了`)
        break
    }
}